﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebUI.DAL;
using WebUI.UserControls;
using WebUI.BL.News;
namespace WebUI.AdminSite.News
{
    public partial class NewsCategoryDetails : System.Web.UI.Page
    {
        private int idCategory;
        protected void Page_Load(object sender, EventArgs e)
        {
            hdfId.Value = Request.QueryString["id"];
            idCategory = (string.IsNullOrEmpty(hdfId.Value)) ? 0 : int.Parse(hdfId.Value);
            if(!IsPostBack)
            {
                BindingData();
            }
        }

        private void BindingData()
        {
            if(idCategory>0)
            {
                var repository=new NewsCategoryBL();
                var n = repository.GetNewsCategoryById(idCategory);
                txtCategoryName.Text = n.CategoryName;
                ckey1.Text = n.Description;
                drpStatus.Text = n.Status;
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var repository = new NewsCategoryBL();
                var n = new tbl_NewsCategory();
                n.CategoryName = txtCategoryName.Text;
                n.Description = ckey1.Text;
                n.Status = drpStatus.SelectedValue;
                n.CategoryNo = idCategory;
                repository.clsNewcategoryModify(n);
            }
            catch (Exception)
            {
                
                throw;
            }
            Response.Redirect(Helpers.link.toAdminNewsCategory("NewsCategory.aspx"));
        }

       

    
    }
}